//#include <stdio.h>
//#include <stdlib.h>
//
//int main() 
//{
//    int n;
//    scanf_s("%d", &n);
//    int* a = (int*)malloc(n * sizeof(int));
//    for (int i = 0; i < n; i++)
//    {
//        scanf_s("%d", &a[i]);
//    }
//
//    int* freq1 = (int*)calloc(n + 1, sizeof(int));
//    int i = 0;
//    int max_len = 0;
//    for (int j = 0; j < n; j++) 
//    {
//        freq1[a[j]]++;
//        while (freq1[a[j]] > 1) 
//        {
//            freq1[a[i]]--;
//            i++;
//        }
//        int current_len = j - i + 1;
//        if (current_len > max_len)
//        {
//            max_len = current_len;
//        }
//    }
//
//    int* freq2 = (int*)calloc(n + 1, sizeof(int));
//    int count_repeat = 0;
//    int* record = (int*)malloc(n * sizeof(int));
//    int count_record = 0;
//
//    for (int k = 0; k < max_len; k++) 
//    {
//        freq2[a[k]]++;
//        if (freq2[a[k]] == 2) 
//        {
//            count_repeat++;
//        }
//    }
//    if (count_repeat == 0)
//    {
//        record[count_record++] = 0;
//    }
//
//    for (int from = 1; from <= n - max_len; from++) 
//    {
//        freq2[a[from - 1]]--;
//        if (freq2[a[from - 1]] == 1) 
//        {
//            count_repeat--;
//        }
//        freq2[a[from + max_len - 1]]++;
//        if (freq2[a[from + max_len - 1]] == 2) 
//        {
//            count_repeat++;
//        }
//        if (count_repeat == 0) 
//        {
//            record[count_record++] = from;
//        }
//    }
//
//    printf("%d\n", count_record);
//    for (int idx = 0; idx < count_record; idx++) 
//    {
//        int l = record[idx] + 1;
//        int r = l + max_len - 1;
//        printf("%d %d\n", l, r);
//    }
//
//    free(a);
//    free(freq1);
//    free(freq2);
//    free(record);
//    return 0;
//}

#include <stdio.h>
#include <stdlib.h>

int main() {
    int n;
    scanf_s("%d", &n);
    int* a = (int*)malloc(n * sizeof(int));
    for (int i = 0; i < n; i++)
    {
        scanf_s("%d", &a[i]);
    }

    int* freq1 = (int*)calloc(n + 1, sizeof(int));
    int i = 0;
    int max_len = 0;
    for (int j = 0; j < n; j++)
    {
        freq1[a[j]]++;
        while (freq1[a[j]] > 1) 
        {
            freq1[a[i]]--;
            i++;
        }
        int current_len = j - i + 1;
        if (current_len > max_len)
        {
            max_len = current_len;
        }
    }

    int* freq2 = (int*)calloc(n + 1, sizeof(int));
    int count_repeat = 0;
    int* record = (int*)malloc(n * sizeof(int));
    int count_record = 0;

    for (int k = 0; k < max_len; k++)
    {
        freq2[a[k]]++;
        if (freq2[a[k]] == 2) 
        {
            count_repeat++;
        }
    }
    if (count_repeat == 0) 
    {
        record[count_record++] = 0;
    }

    for (int from = 1; from <= n - max_len; from++) 
    {
        freq2[a[from - 1]]--;
        if (freq2[a[from - 1]] == 1)
        {
            count_repeat--;
        }
        freq2[a[from + max_len - 1]]++;
        if (freq2[a[from + max_len - 1]] == 2) 
        {
            count_repeat++;
        }
        if (count_repeat == 0) 
        {
            record[count_record++] = from;
        }
    }

    printf("%d\n", count_record);
    for (int idx = 0; idx < count_record; idx++)
    {
        int l = record[idx] + 1;
        int r = l + max_len - 1;
        printf("%d %d\n", l, r);
    }

    free(a);
    free(freq1);
    free(freq2);
    free(record);
    return 0;
}